package com.pj.wisdomlogistics.ui.activity;

import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;

import com.pj.wisdomlogistics.R;
import com.pj.wisdomlogistics.other.EventCenter;
import com.pj.wisdomlogistics.ui.adapter.GuidePagerAdapter;
import com.pj.wisdomlogistics.utils.ActivityManagerUtil;
import com.rd.PageIndicatorView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class GuideActivity extends BaseActivity implements ViewPager.OnPageChangeListener {
    @BindView(R.id.vp_guide)
    ViewPager mVpGuide;
    @BindView(R.id.pageIndicatorView)
    PageIndicatorView mIndicator;
    @BindView(R.id.bt_start)
    TextView mBtStart;
    private List<Integer> mImages = new ArrayList<>();
    private GuidePagerAdapter mGuidePagerAdapter;

    @Override
    public void initView() {
        ultimateBar.setImmersionBar();

        mImages.add(R.drawable.text_page);
        mImages.add(R.drawable.text_page);
        mImages.add(R.drawable.text_page);

        mGuidePagerAdapter = new GuidePagerAdapter(mImages);
        mVpGuide.setAdapter(mGuidePagerAdapter);

        mVpGuide.addOnPageChangeListener(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mVpGuide.removeOnPageChangeListener(this);

    }

    @Override
    public void initData() {

    }

    @Override
    public int getContentView() {
        return R.layout.activity_guide;
    }

    @Override
    public boolean isApplyEventBus() {
        return false;
    }

    @Override
    public boolean isApplyButterKnife() {
        return true;
    }

    @Override
    public void onEventCome(EventCenter eventCenter) {

    }


    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

    }

    @Override
    public void onPageSelected(int position) {
        if (position == mImages.size() - 1) {

            mBtStart.setVisibility(View.VISIBLE);
        } else {

            mBtStart.setVisibility(View.INVISIBLE);
        }
    }

    @Override
    public void onPageScrollStateChanged(int state) {

    }


    @OnClick(R.id.bt_start)
    public void onClick() {
        startActivity(LoginActivity.class);
        ActivityManagerUtil.create().finishActivity(this);
    }
}
